<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#assign css>
<style>
</style>
</#assign>
<#assign js>
<script>
	function pass(id) {
		layer.confirm('确定已转账吗?', {icon: 3, title: '提示'}, function (index) {
			$.ajax({
				type: "POST",
				dataType: "json",
				url: "/agentDrawApply/pass/" + id,
				success: function (res) {
					layer.msg(res.message, {time: 2000}, function () {
						location.reload();
					});
				}
			});
		});
	}

	function reject(id){

        layer.prompt({title: '输入提现失败原因', formType: 2}, function(reason, index){

            $.ajax({
                type: "POST",
                dataType: "json",
				data:{reason:reason},
                url: "/agentDrawApply/reject/" + id,
                success: function (res) {
                    layer.msg(res.message, {time: 2000}, function () {
                        location.reload();
                    });
                }
            });


        });


	}


	//tableId,queryId,conditionContainer
	//var userTable;
	var winId="userWin";
	$(function() {
		//init table and fill data
		//userTable = new CommonTable("user_table", "user_list", "searchDiv");

		//button event
		$('button[data-btn-type]').click(function() {
			var action = $(this).attr('data-btn-type');
			var rowId="ceshi";
			switch (action) {
				case 'add':
					modals.openWin({
						winId:winId,
						title:'新增分站提现申请',
						width:'900px',
						url:"/agentDrawApply/edit/ceshi"
					});
					break;
				case 'edit':
					if(!rowId){
						modals.info('请选择要编辑的行');
						return false;
					}
					modals.openWin({
						winId:winId,
						title:'编辑分站提现申请【'+userTable.getSelectedRowData().name+'】',
						width:'900px',
						url:"/agentDrawApply/edit/"+rowId,
					});
					break;
				case 'delete':
					if(!rowId){
						modals.info('请选择要删除的行');
						return false;
					}
					modals.confirm("是否要删除该行数据？",function(){
						ajaxPost(basePath+"/agentDrawApply/delete/"+rowId,null,function(data){
							if(data.success){
								//modals.correct("已删除该数据");
								userTable.reloadRowData();
							}else{
								modals.error("分站提现申请数据被引用，不可删除！");
							}
						});
					})
					break;
			}

		});
		//form_init();
	});
</script>
</#assign>
<@layout title="分站提现申请管理" active="agentDrawApply">
<!-- Content Header (Page header) -->

<!-- Main content -->
<section class="content">
	<!-- Default box -->
	<div class="box box-primary">
		<div class="box-header">

            <form class="form-horizontal form-edit" method="post" action="/agentDrawApply/index" id="form">
                <div class="form-group" style="margin-top:10px;">
                    <div class="col-sm-2">
                        <input  placeholder="请输入分站名称" id="agentName" name="agentName" class="form-control" type="text" value="${apply.agentName!}" >
                    </div>
                    <div class="col-sm-2">
                        <select name="status" class="form-control" >
                            <option value="">转账状态</option>
                            <option value="1" selected>待付款</option>
                            <option value="2">提现成功</option>
                            <option value="3">提现失败</option>
                            <#--<option value="4">已取消</option>-->

                        </select>
                    </div>
                    <div class="btn-group">
                        <button type="submit" class="btn btn-primary" data-btn-type="search">查询</button>
                        <button type="button" class="btn btn-default" data-btn-type="reset" onclick="javascript:$('#form')[0].reset();">重置</button>
                    </div>
                </div>
            </form>

		</div>
		<div class="box-body">
			<table class="table table-striped">
				<tr>
					<th></th>
					<th>分站名称</th>
                    <th>银行卡号</th>
                    <th>户名</th>
                    <th>开户银行</th>
					<th>申请提现金额</th>
					<th>手续费</th>
					<th>到账金额</th>

					<th>提现申请状态</th>
					<th>申请时间</th>
					<#--<th>审核人</th>-->
					<#--<th>审核时间</th>-->
					<th>操作</th>
				</tr>
                <#list pageInfo.list as item>
                <tr>
					<td >${item.id!}</td>

					<td >${item.agentName!}</td>
                    <td >${item.account!}</td>
                    <td >${item.accountName!}</td>
                    <td >${item.openBank!}</td>
					<td >${item.amount?string('0.00')!}</td>
					<td >${item.fee?string('0.00')!}</td>
                    <td >${(item.amount - item.fee)?string('0.00')!}</td>

					<td >

						<#if item.status ==1>
							待付款
						</#if>
						<#if item.status ==2>
							提现成功
						</#if>
						<#if item.status ==3>
							提现失败
						</#if>
						<#if item.status ==4>
							已取消
						</#if>
					</td>
					<td >${item.createAt?string('yyyy-MM-dd HH:mm:ss')}</td>
					<#--<td >${item.checkBy!}</td>-->
					<#--<td >${item.checkAt!}</td>-->
					<td>
					<#if item.status ==1>
                        	<button class="btn btn-sm btn-success" onclick="pass('${item.id}')">已付款</button>
                        	<button class="btn btn-sm btn-danger" onclick="reject('${item.id}')">交易失败</button>
					</#if>


					</td>
				</tr>
                </#list>
			</table>
		</div>
		<!-- /.box-body -->
		<div class="box-footer clearfix">
            <@macro.page pageInfo=pageInfo url="/agentDrawApply/index?" />
		</div>
	</div>
	<!-- /.box -->

</section>
<!-- /.content -->
</@layout>
